package com.linkdood.app.web;

import com.linkdood.app.service.AccountService;
import com.linkdood.app.service.impl.DdioSynchronize;
import com.linkdood.app.service.ThirdPartyService;
import com.linkdood.app.service.UserService;
import com.linkdood.app.web.rest.UserResource;
import org.junit.jupiter.api.BeforeEach;
import org.mockito.MockitoAnnotations;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;

@SpringBootTest
@ActiveProfiles("test")
public class UserResourceIT {

    @Autowired
    private HttpMessageConverter<?>[] httpMessageConverters;

    private UserService userService;

    private AccountService accountService;

    private ThirdPartyService thirdPartyService;

    private DdioSynchronize ddioSynchronize;

    private MockMvc restMvc;

    private MockMvc restUserMockMvc;

    @BeforeEach
    public void setup() {
        MockitoAnnotations.initMocks(this);

        UserResource doodUserResource = new UserResource(userService, accountService, thirdPartyService, ddioSynchronize);
        this.restMvc = MockMvcBuilders.standaloneSetup(doodUserResource)
            .setMessageConverters(httpMessageConverters)
//                .setControllerAdvice(exceptionTranslator)   // FIXME: 之后使用
            .build();
        this.restUserMockMvc = MockMvcBuilders.standaloneSetup(doodUserResource)
//                .setControllerAdvice(exceptionTranslator)
            .build();
    }

}
